<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>条形码组件</title>
    <link rel="stylesheet" th:href="@{/layuimini/lib/layui-v2.6.3/css/layui.css}" media="all">
    <link rel="stylesheet" th:href="@{/layuimini/css/public.css}" media="all">
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">
        <div class="ok-body">
            <blockquote class="layui-elem-quote" style="padding: 5px;">
                1.layui第三方扩展组件：<font color="red" size="2">二维码(qrcode)</font>；
                <br/>
                2.本项目主要暂未使用到该组件；
            </blockquote>
            <button type="button" class="layui-btn layui-bg-blue" id="qrcodeBtn">生成二维码</button>
            <div class="qr-box">
                <div id="qrcode"></div>
            </div>

            <pre>
            // Step1. 引入依赖
            let qrcode = layui.qrcode;
			<br/>

            // Step2. 使用(方式一)
            new qrcode($("#qrcode")[0], {
                width: 200,
                height: 200,
                background: "transparent",    //二维码的后景色（默认透明色）
                foreground: "#000000",        //二维码的前景色（默认黑色）
                text: "https://www.baidu.com/"
            });
            <br/>
		    </pre>
        </div>
    </div>
</div>

<script th:src="@{/layuimini/lib/layui-v2.6.3/layui.js}" charset="utf-8"></script>
<script th:src="@{/layuimini/js/lay-config.js?v=1.0.4}" charset="UTF-8"></script>
<script type="text/javascript" th:inline="javascript">
    layui.use(['code', 'jquery', 'qrcode'], function () {
        let code = layui.code,
            qrcode = layui.qrcode,
            $ = layui.jquery;

        let ctxPath = /*[[@{/}]]*/'';

        code({
            elem: "pre",
            title: "代码示例",
            skin:'notepad', //设置显示风格
            about: false
        });

        $("#qrcodeBtn").click(function () {
            new qrcode($("#qrcode")[0], {
                width: 60,
                height: 60,
                background: "transparent",
                foreground: "#000000",
                text: ctxPath
            });
        });
    });
</script>
</body>
</html>
